namespace Legend.Fakes.Api
{
    /// <summary>
    /// Allows for intercepting call to a fake object and
    /// act upon them.
    /// </summary>
    public interface IFakeObjectCallRule
    {
        /// <summary>
        /// Gets wether this interceptor is applicable to the specified
        /// call, if true is returned the Apply-method of the interceptor will
        /// be called.
        /// </summary>
        /// <param name="call">The call to check for applicability.</param>
        /// <returns>True if the interceptor is applicable.</returns>
        bool IsApplicableTo(IFakeObjectCall call);

        /// <summary>
        /// Applies an action to the call, might set a return value or throw
        /// an exception.
        /// </summary>
        /// <param name="call">The call to apply the interceptor to.</param>
        void Apply(IWriteableFakeObjectCall call);

        /// <summary>
        /// Gets the number of times this interceptor is valid, if it's set
        /// to null its valid as long as there are no valid calls after it.
        /// </summary>
        int? NumberOfTimesToCall { get; }

        /// <summary>
        /// When this is set to true, the verify method of fake throws
        /// an exception if this call has been made more times than the
        /// NumberOfTimesToCall property.
        /// </summary>
        bool MayNotBeCalledMoreThanTheNumberOfTimesSpecified { get; }

        /// <summary>
        /// If set to true the verify method of the fake object will throw
        /// if the call has not been made the specified number of times.
        /// </summary>
        bool MustGetCalled { get; }
    }
}